#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>

int main (void)
{
	void *ptr = NULL;
	pid_t pid;
	ptr = mmap (NULL, 1024, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
	if (MAP_FAILED == ptr) {
		perror ("mmap()");
		return -1;
	}
	pid = fork ();
	if (-1 == pid) {
		perror ("fork()");
		goto ERROR;
	}
	if (pid == 0) {
		memcpy (ptr, "hello world!", 12);
		munmap (ptr, 1024);
		exit (0);
	}
	wait (NULL);
	puts (ptr);
	return 0;
ERROR:
	munmap (ptr, 1024);
	exit (1);
}



